/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            adminShopVipInfo: {
                vips: [],
                total: 0,
                records: 1,
                moreCondition: false,
                vipId: '',
                conditions: {
                    vipName: '',
                    vipTel: '',
                    vipLevel: '',
                    shopId:''
                }
            }
        },
        _initMethod: function () {
            vc.emit('adminShop', 'initShop',function(_shop){
                $that.adminShopVipInfo.conditions.shopId = _shop.shopId;
                $that._listShopVipUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            $that._listShopVipUsers(DEFAULT_PAGE, DEFAULT_ROWS);
        },
        _initEvent: function () {
            vc.on('adminShopVip', 'listShopVipUser', function (_param) {
                $that._listShopVipUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listShopVipUsers(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listShopVipUsers: function (_page, _rows) {
                $that.adminShopVipInfo.conditions.page = _page;
                $that.adminShopVipInfo.conditions.row = _rows;
                let param = {
                    params: $that.adminShopVipInfo.conditions
                };
                //发送get请求
                vc.http.apiGet('/shopVipUser.queryAdminVipUser',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.adminShopVipInfo.total = _json.total;
                        $that.adminShopVipInfo.records = _json.records;
                        $that.adminShopVipInfo.vips = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.adminShopVipInfo.records,
                            dataCount: $that.adminShopVipInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
          
            //查询
            _queryShopVipUserMethod: function () {
                $that._listShopVipUsers(DEFAULT_PAGE, DEFAULT_ROWS);
            },
           
            _moreCondition: function () {
                if ($that.adminShopVipInfo.moreCondition) {
                    $that.adminShopVipInfo.moreCondition = false;
                } else {
                    $that.adminShopVipInfo.moreCondition = true;
                }
            },
        }
    });
})(window.vc);
